<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<%@ taglib prefix="f" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	String path=request.getContextPath();
%>    

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
	<link href="/resources/css/bootstrap-4.3.1/css/bootstrap.css" rel="stylesheet">
	<script type="text/javascript" src="/resources/js/jquery-3.2.1/jquery.js"></script>
	<script type="text/javascript" src="/resources/js/jqueryvalidate/jquery.validate.js"></script>
	<script type="text/javascript" src="/resources/js/jqueryvalidate/localization/messages_zh.js"></script>
	<script type="text/javascript" src="/resources/css/bootstrap-4.3.1/js/bootstrap.js"></script>
</head>
<body>

	<div class = "container">
		<div class = "row">
			<div class = "col-md-3" >
				<form action="/" method="post">
				  
				  <div class="form-group">
				    <label for="exampleInputPassword1">学生姓名</label>
				    <input type="text" class="form-control" name = "name">
				  </div>
				  
				  <div class="form-group form-check">
				    <input type="checkbox" class="form-check-input" name = "ids" value = "1">
				    <label class="form-check-label" for="exampleCheck1">计算机原理</label>
				  </div>
				  <div class="form-group form-check">
				    <input type="checkbox" class="form-check-input" name = "ids" value = "2">
				    <label class="form-check-label" for="exampleCheck1">数据结构</label>
				  </div>
				  <div class="form-group form-check">
				    <input type="checkbox" class="form-check-input" name = "ids" value = "3">
				    <label class="form-check-label" for="exampleCheck1">编译原理</label>
				  </div>
				  <div class="form-group form-check">
				    <input type="checkbox" class="form-check-input" name = "ids" value = "4">
				    <label class="form-check-label" for="exampleCheck1">汇编语言</label>
				  </div>
				  
				  <button type="submit" class="btn btn-primary">查询</button>
				</form>
				<a href="toAddStudent"><input type = "button" class="btn btn-primary" value = "添加"></a> 
				<input type = "button" class="btn btn-primary" value = "批量删除" onclick = "delById()">
				
				
			</div>
			<div class = "col-md-9">
			<form action="del" name = "delForm" method="post" id = "delForm">
			<table class = "table">
				<tr>
					<td>
						<input type = "checkbox"  id = "cka">
					</td>
					<td>编号</td>
					<td>姓名</td>
					<td>创建时间</td>
					<td>学生地址</td>
					<td>选修课</td>
					<td>操作</td>
				</tr>
				<c:forEach items="${studnetPage.list }" var="stu">
					<tr>
						<td>
								<input type = "checkbox" class = "cka" name = "list" value = "${stu.id }">
							</td>
							<td>${stu.id }</td>
							<td>${stu.name }</td>
							<td>
								<fmt:formatDate value="${stu.created }" pattern="yyyy-MM-dd"/>
							</td>
							<td>
							${stu.province.name }-
							${stu.city.name }-
							${stu.county.name }
							</td>
							<td>${stu.strMajor }</td>
							<td>
								  <a href="toUpdate?id=${stu.id }"><input type = "button" class="btn btn-primary"  value = "修改"></a>
							
							</td>
					</tr>
				</c:forEach>
	

	
			</table>
			</form>
			
			<nav aria-label="Page navigation example">
			  <ul class="pagination">
			    <li class="page-item"><a class="page-link" href="/?pageNum=1">首页</a></li>
			    <c:forEach begin="${studnetPage.pageNum-2>1?studnetPage.pageNum-2:1}" 
				       end="${studnetPage.pageNum+2<studnetPage.pages ? studnetPage.pageNum+2:studnetPage.pages}" step="1" var="page">
				    	<c:if test="${page==studnetPage.pageNum}">
				    		<li class="page-item active" aria-current="page">
						      <a class="page-link">
						         ${page}
						        <span class="sr-only">(current)</span>
						      </a>
						    </li>
				    	</c:if>
				    	<c:if test="${page!=studnetPage.pageNum}">
		    		<li class="page-item"><a class="page-link" href="/?pageNum=${page }" >${page}</a></li>
		    		</c:if>    	
		    		</c:forEach>
			    <li class="page-item"><a class="page-link" href="/?pageNum=${studnetPage.pages }">尾页</a></li>
			  </ul>
			</nav>
			</div>
			
		
		
		
		
		
		
		</div>
	
	
	
	</div>
	<script type="text/javascript">
	
	
		$("#cka").click(function(){
			
			$(".cka").prop("checked",this.checked);
				
			
		})
		
		function delById(){
			
			
			alert("11");
		 
			$.post("delById",$("#delForm").serialize(),function(msg){
				
				if(msg > 0){
					alert("删除成功");
					location = "/";
				}else{
					alert("删除失败");
				}
				
			}) 	
			
		}
	
	
	
	
	
	
	
	
	
	
	
	
	
	</script>
	
	
	
</body>
</html>